<template>
  <el-dialog v-model="dialog" title="修改采购商" width="600px" :close-on-click-modal="false">
    <div style="display: flex; justify-content: space-around;">
      <el-button type="text" @click="export1">运营分析表</el-button>
      <el-button type="text" @click="export2">客户信息跟进表</el-button>
      <el-button type="text" @click="export3">回访记录表</el-button>
    </div>
    <template #footer>
      <el-button @click="dialog = false;">关闭</el-button>
    </template>
  </el-dialog>
</template>

<script setup>
  
  import {
    ref,
    inject
  } from 'vue'
  
  const $post = inject('$post');
  const $export = inject('$export');
  const $message = inject('$message');
  
  const dialog = ref(false);
  
  let form = {};
  
  const export1 = () => {
    $post('/tdltry/listempexport_analy', form).then(res => {
      if (res.data) {
        $export(`/servlet/downloadFile?file=${encodeURI(res.data)}&newFileName=${encodeURI('运营分析表.xls')}`);
      } else {
        $message.info(res.msg);
      }
    })
  }
  
  const export2 = () => {
    $post('/tdltry/listempexports', form).then(res => {
      if (res.data) {
        $export(`/servlet/downloadFile?file=${encodeURI(res.data)}&newFileName=${encodeURI('客户信息跟进表.xls')}`);
      } else {
        $message.info(res.msg);
      }
    })
  }
  
  const export3 = () => {
    $post('/tdltry/listempexport_visit', form).then(res => {
      if (res.data) {
        $export(`/servlet/downloadFile?file=${encodeURI(res.data)}&newFileName=${encodeURI('回访记录表.xls')}`);
      } else {
        $message.info(res.msg);
      }
    })
  }
  
  defineExpose({
    show: function (params) {
      dialog.value = true;
      form = params;
    }
  });
  
  
  
</script>

<style>
</style>
